//============================================================================================
/**
 * @file	bag_bmp.c
 * @brief	バッグ画面BMP処理
 * @author	Hiroyuki Nakamura
 * @date	05.11.28
 */
//============================================================================================
#include "common.h"
#include "system/gamedata.h"
#include "system/procsys.h"
#include "system/window.h"
#include "system/bmp_list.h"
#include "system/bmp_menu.h"
#include "system/clact_util.h"
#include "system/clact_tool.h"
#include "system/pmfprint.h"
#include "system/pm_str.h"
#include "system/fontproc.h"
#include "system/msgdata.h"
#include "system/msgdata_util.h"
#include "system/numfont.h"
#include "system/wordset.h"
#include "system/buflen.h"
#include "system/snd_tool.h"
#include "gflib/strbuf_family.h"
#include "savedata/config.h"
#include "itemtool/item.h"
#include "battle/battle_common.h"
#include "poketool/waza_tool.h"
#include "msgdata/msg.naix"
#include "msgdata/msg_bag.h"
#include "msgdata/msg_itempocket.h"

#define	BAG_BMP_H_GLOBAL
#include "application/bag.h"
#include "bag_main.h"
#include "bag_bmp.h"
#include "bag_obj.h"
#include "bag_gra.naix"


//============================================================================================
//	定数定義
//============================================================================================
#define	POCKET_NAME_AREA_SX		( 96 )		// ポケット名表示エリアXサイズ
#define	POCKET_NAME_AREA_GX		( 50 )		// ポケット名表示基準X座標
#define	POCKET_NAME_SCROLL_X	( 12 )		// １カウントスクロールするドット数

#define	MENU_INFO_STRLEN	( BMP_MENU_INFO_SX*2*2 )	// メニュー説明文字列サイズWinSiz * 2行 * 海外対応

#define	NUMSEL_EX		( BMP_SALE_NUM_SX * 8 )		// 売却額の右端のX座標

#define	NORMAL_INFO_PX	( 40 )		// アイテム情報表示X座標

#define	INFO_TYPE_PX	( 0 )		// 技マシン情報 「タイプ」表示X座標
#define	INFO_TYPE_PY	( 0 )		// 技マシン情報 「タイプ」表示Y座標
#define	INFO_PP_PX		( 0 )		// 技マシン情報 「PP」表示X座標
#define	INFO_PP_PY		( 16 )		// 技マシン情報 「PP」表示Y座標
#define	INFO_KIND_PX	( 72 )		// 技マシン情報 「ぶんるい」表示X座標
#define	INFO_KIND_PY	( 0 )		// 技マシン情報 「ぶんるい」表示Y座標
#define	INFO_POW_PX		(168 )		// 技マシン情報 「いりょく」表示X座標
#define	INFO_POW_PY		(  0 )		// 技マシン情報 「いりょく」表示Y座標
#define	INFO_HIT_PX		(168 )		// 技マシン情報 「めいちゅう」表示X座標
#define	INFO_HIT_PY		( 16 )		// 技マシン情報 「めいちゅう」表示YX座標
#define	INFO_PPNUM_PX	( 48 )		// 技マシン情報 PP値表示X座標
#define	INFO_PPNUM_PY	( 16 )		// 技マシン情報 PP値表示Y座標
#define	INFO_POWNUM_PX	(168+64 )	// 技マシン情報 威力値表示X座標
#define	INFO_POWNUM_PY	(  0 )		// 技マシン情報 威力値表示Y座標
#define	INFO_HITNUM_PX	(168+64 )	// 技マシン情報 命中値表示X座標
#define	INFO_HITNUM_PY	( 16 )		// 技マシン情報 命中値表示Y座標

#define	NX_POS_PX	( 100 )				// 「ｘ」表示X座標（通常）
#define	WX_POS_PX	( NX_POS_PX+12 )	// 「ｘ」表示X座標（技マシン）
#define	NUM_POS_EX	( 17*8-2 )			// 個数表示X座標終端
#define	NUM_BUFLEN	( 10 )				// ("x???"+EOM_) x 海外

#define WAZANAME_X		( 30 )		// 技マシン表示の際の文字列を右に移動させるオフセットサイズ

#define	WM_NO_Y_PLUS	( 5 )		// 技マシンの「No」表示Y座標オフセット

#define	LIST_FILL_SY	( 16 )		// 技マシンポケットの「とじる」を表示するためのYサイズ

#define	LIST_ICON_SX	( 104 )		// 「ひでん」「とうろく」アイコンのキャラデータサイズX
#define	LIST_ICON_SY	( 16 )		// 「ひでん」「とうろく」アイコンのキャラデータサイズY

#define	HIREN_ICON_PX	( 0 )		// 「ひでん」アイコンのキャラデータの開始X座標
#define	HIREN_ICON_PY	( 0 )		// 「ひでん」アイコンのキャラデータの開始Y座標
#define	HIREN_ICON_SX	( 24 )		// 「ひでん」アイコンのキャラデータのXサイズ
#define	HIREN_ICON_SY	( 16 )		// 「ひでん」アイコンのキャラデータのYサイズ

#define	CNV_ICON1_PX			( 24 )	// 「とうろく」アイコンのキャラデータの開始X座標
#define	CNV_ICON1_PY			(  0 )	// 「とうろく」アイコンのキャラデータの開始Y座標
#define	CNV_ICON2_PX			( 64 )	// 「とうろく」アイコンのキャラデータの開始X座標
#define	CNV_ICON2_PY			(  0 )	// 「とうろく」アイコンのキャラデータの開始Y座標
#define	CNV_ICON_SX			( 40 )	// 「とうろく」アイコンのキャラデータのXサイズ
#define	CNV_ICON_SY			( 16 )	// 「とうろく」アイコンのキャラデータのYサイズ
#define	CNV_ICON_SCRPUT_X	(  0 )	// 「とうろく」アイコンの表示X座標

#define	GOLD_EX			( BMP_GOLD_SX * 8 )		// 所持金表示の終端X座標

#define BAG_COUNT_NUM	( 3 )		// 数値表示に使用するBMPの数

//============================================================================================
//	プロトタイプ宣言
//============================================================================================
static void BAG_HidenIconPut( BAG_WORK * wk, GF_BGL_BMPWIN *win, u32 py );

static void BAG_WazaMashinePPPut( BAG_WORK * wk, u16 item );

static BOOL BAG_TalkMsgCallBack( MSG_PRINT_HEADER * mph, u16 value );
static int GetPocketItemRoute( POCKET_DATA *p, int index, int target );
static void	ItemNumPrint( WORDSET *wset, MSGDATA_MANAGER *msg_man, GF_BGL_BMPWIN *win, int num );
static void itemname_print( BAG_WORK *wk,  GF_BGL_BMPWIN *win, STRBUF *str, POCKET_DATA *pocket, int index );

static void BagBmp_CnvButtonIconPut( BAG_WORK * wk, GF_BGL_BMPWIN *win, u32 py, int button );

static void SelectItemBmp_WinDelete( BAG_WORK *wk );
static void SelectItemBmp_WinInit( BAG_WORK *wk );
static void ItemListBmp_WinDelete( BAG_WORK *wk );
static void ItemListBmp_WinInit( BAG_WORK *wk );


//============================================================================================
//	グローバル変数
//============================================================================================
// はい・いいえ
static const BMPWIN_DAT YesNoBmpWin = {
	BMP_YESNO_FRM, BMP_YESNO_PX, BMP_YESNO_PY,
	BMP_YESNO_SX, BMP_YESNO_SY, BMP_YESNO_PAL, BMP_YESNO_CGX
};

static const int BmpItemTable[][3]={
	{ BMP_ITEM0_PX, BMP_ITEM0_PY, BMP_LIST_CGX + (BMP_ITEM_W*BMP_ITEM_H)*0 },
	{ BMP_ITEM1_PX, BMP_ITEM1_PY, BMP_LIST_CGX + (BMP_ITEM_W*BMP_ITEM_H)*1 },
	{ BMP_ITEM2_PX, BMP_ITEM2_PY, BMP_LIST_CGX + (BMP_ITEM_W*BMP_ITEM_H)*2 },
	{ BMP_ITEM3_PX, BMP_ITEM3_PY, BMP_LIST_CGX + (BMP_ITEM_W*BMP_ITEM_H)*3 },
	{ BMP_ITEM4_PX, BMP_ITEM4_PY, BMP_LIST_CGX + (BMP_ITEM_W*BMP_ITEM_H)*4 },
	{ BMP_ITEM5_PX, BMP_ITEM5_PY, BMP_LIST_CGX + (BMP_ITEM_W*BMP_ITEM_H)*5 },

	{ BMP_ITEM0_PX, BMP_ITEM0_PY, BMP_LIST_CGX + (BMP_ITEM_W*BMP_ITEM_H)*6 },
	{ BMP_ITEM1_PX, BMP_ITEM1_PY, BMP_LIST_CGX + (BMP_ITEM_W*BMP_ITEM_H)*7 },
	{ BMP_ITEM2_PX, BMP_ITEM2_PY, BMP_LIST_CGX + (BMP_ITEM_W*BMP_ITEM_H)*8 },
	{ BMP_ITEM3_PX, BMP_ITEM3_PY, BMP_LIST_CGX + (BMP_ITEM_W*BMP_ITEM_H)*9 },
	{ BMP_ITEM4_PX, BMP_ITEM4_PY, BMP_LIST_CGX + (BMP_ITEM_W*BMP_ITEM_H)*10 },
	{ BMP_ITEM5_PX, BMP_ITEM5_PY, BMP_LIST_CGX + (BMP_ITEM_W*BMP_ITEM_H)*11 },
};

static const int BmpSelectMenuTable[][2]={
	{ BMP_SELECT0_PX, BMP_SELECT0_PY, },
	{ BMP_SELECT1_PX, BMP_SELECT1_PY, },
	{ BMP_SELECT2_PX, BMP_SELECT2_PY, },
	{ BMP_SELECT3_PX, BMP_SELECT3_PY, },
};

static const int BmpNumTable[][2]={
	{ BMP_NUM_100_PX, BMP_NUM_100_PY, },
	{ BMP_NUM_10_PX,  BMP_NUM_10_PY, },
	{ BMP_NUM_1_PX,   BMP_NUM_1_PY, },
};

//--------------------------------------------------------------------------------------------
/**
 * @brief	BMPウィンドウ設定
 *
 * @param	wk		バッグ画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void BagBmpWinSet( BAG_WORK * wk )
{
	int i;

	// 情報表示ウインドウ
	GF_BGL_BmpWinAdd(
		wk->bgl, &wk->win[WIN_INFO], BMP_INFO_FRM,
		BMP_INFO_PX, BMP_INFO_PY, BMP_INFO_SX, BMP_INFO_SY, BMP_INFO_PAL, BMP_INFO_CGX );
	// わざ情報ウインドウ
	GF_BGL_BmpWinAdd(
		wk->bgl, &wk->win[WIN_WAZA_INFO], BMP_WAZA_INFO_FRM,
		BMP_WAZA_INFO_PX, BMP_WAZA_INFO_PY, BMP_WAZA_INFO_SX, BMP_WAZA_INFO_SY,
		BMP_WAZA_INFO_PAL, BMP_WAZA_INFO_CGX );

	// メニュー情報
	GF_BGL_BmpWinAdd(
		wk->bgl, &wk->win[WIN_MENU_INFO],
		BMP_MENU_INFO_FRM, BMP_MENU_INFO_PX, BMP_MENU_INFO_PY,
		BMP_MENU_INFO_SX, BMP_MENU_INFO_SY, BMP_MENU_INFO_PAL, BMP_MENU_INFO_CGX );

	// 会話ウインドウ（現在は上画面）
	GF_BGL_BmpWinAdd(
		wk->bgl, &wk->win[WIN_TALK],
		BMP_TALK_FRM, BMP_TALK_PX, BMP_TALK_PY,
		BMP_TALK_SX, BMP_TALK_SY, BMP_TALK_PAL, BMP_TALK_CGX );

	// いくつ売る？
	GF_BGL_BmpWinAdd(
		wk->bgl, &wk->win[WIN_SALE_NUM],
		BMP_SALE_NUM_FRM, BMP_SALE_NUM_PX, BMP_SALE_NUM_PY,
		BMP_SALE_NUM_SX, BMP_SALE_NUM_SY, BMP_SALE_NUM_PAL, BMP_SALE_NUM_CGX );

	// ポフィン情報
	GF_BGL_BmpWinAdd(
		wk->bgl, &wk->win[WIN_PORUTO],
		BMP_PORUTO_FRM, BMP_PORUTO_PX, BMP_PORUTO_PY,
		BMP_PORUTO_SX, BMP_PORUTO_SY, BMP_PORUTO_PAL, BMP_PORUTO_CGX );

	// 現在のページ数
	GF_BGL_BmpWinAdd(
		wk->bgl, &wk->win[WIN_PAGE],
		BMP_PAGE_FRM, BMP_PAGE_PX, BMP_PAGE_PY,
		BMP_PAGE_W, BMP_PAGE_H, BMP_PAGE_PAL, BMP_PAGE_CGX );
	GF_BGL_BmpWinDataFill( &wk->win[WIN_PAGE], 0 );

	// やめる
	GF_BGL_BmpWinAdd(
		wk->bgl, &wk->win[WIN_CANCEL],
		BMP_CANCEL_FRM, BMP_CANCEL_PX, BMP_CANCEL_PY,
		BMP_CANCEL_W, BMP_CANCEL_H, BMP_CANCEL_PAL, BMP_CANCEL_CGX );
	GF_BGL_BmpWinDataFill( &wk->win[WIN_CANCEL], 0 );

	// 追加BMP用ポインタのNULLクリア
	for(i=0;i<ADD_SUB_WIN_MAX;i++){
		wk->sub_win[i].ini = NULL;
	}

	OS_Printf("BMP_SELECT_CGX=%d\n",BMP_SELECT_CGX);
	OS_Printf("MENU_WIN_CGX_NUM=%d\n",MENU_WIN_CGX_NUM);
	OS_Printf("TALK_WIN_CGX_NUM=%d\n",TALK_WIN_CGX_NUM);
}

//--------------------------------------------------------------------------------------------
/**
 * @brief	BMPウィンドウ破棄
 *
 * @param	wk		バッグ画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void BagBmpWinExit( BAG_WORK *wk )
{
	u16	i;

	for( i=0; i<WIN_MAX; i++ ){
		GF_BGL_BmpWinDel( &wk->win[i] );
	}

	SelectItemBmp_WinDelete( wk );
	ItemListBmp_WinDelete( wk );

}

//------------------------------------------------------------------
/**
 * @brief   どうぐリストBMP領域の確保
 *
 * @param	wk		バッグ画面ワーク
 *
 * @retval  none
 */
//------------------------------------------------------------------
static void ItemListBmp_WinInit( BAG_WORK *wk )
{
	int i;
	// ２重確保をさせない
	if(wk->sub_win[ADD_WIN_ITEM0].ini!=NULL){
		return;
	}


	// どうぐの名前表示用BMP
	for(i=0;i<BAG_PAGE_ITEM_NUM*2;i++){
		GF_BGL_BmpWinAdd(
			wk->bgl, &wk->sub_win[ADD_WIN_ITEM0+i], BMP_LIST_FRM,
			BmpItemTable[i][0], BmpItemTable[i][1], BMP_ITEM_W, BMP_ITEM_H, BMP_LIST_PAL, BmpItemTable[i][2] );
	}
}

//------------------------------------------------------------------
/**
 * @brief   どうぐリストBMP領域の解放
 *
 * @param	wk		バッグ画面ワーク
 *
 * @retval  none
 */
//------------------------------------------------------------------
static void ItemListBmp_WinDelete( BAG_WORK *wk )
{
	int i;

	// ポインタがNULLの場合は抜ける
	if(wk->sub_win[ADD_WIN_ITEM0].ini==NULL){
		return;
	}

	// どうぐの名前表示用BMP
	for(i=0;i<BAG_PAGE_ITEM_NUM*2;i++){
		GF_BGL_BmpWinOffVReq( &wk->sub_win[ADD_WIN_ITEM0+i] );
		GF_BGL_BmpWinDel( &wk->sub_win[ADD_WIN_ITEM0+i] );
		wk->sub_win[ADD_WIN_ITEM0+i].ini = NULL;
	}
}


//------------------------------------------------------------------
/**
 * @brief   選択した道具と選択肢４つのBMP領域確保
 *
 * @param	wk		バッグ画面ワーク
 *
 * @retval  none
 */
//------------------------------------------------------------------
static void SelectItemBmp_WinInit( BAG_WORK *wk )
{
	int i;

	// ２重確保回避
	if(wk->sub_win[ADD_WIN_SELECT_ITEM].ini!=NULL){
		return;
	}

	// 選択されたどうぐ名を描画する領域
	GF_BGL_BmpWinAdd(
		wk->bgl, &wk->sub_win[ADD_WIN_SELECT_ITEM],
		BMP_SELECTITEM_FRM, BMP_SELECTITEM_PX, BMP_SELECTITEM_PY,
		BMP_SELECTITEM_W, BMP_SELECTITEM_H, BMP_SELECTITEM_PAL, BMP_SELECTITEM_CGX );
	GF_BGL_BmpWinDataFill( &wk->sub_win[ADD_WIN_SELECT_ITEM], 0 );

	// ４つの選択肢
	for(i=0;i<BAG_SELECT_MENU_PLATE_NUM;i++){
		GF_BGL_BmpWinAdd(
			wk->bgl, &wk->sub_win[ADD_WIN_SELECT0+i],
			BMP_SELECT_FRM, BmpSelectMenuTable[i][0], BmpSelectMenuTable[i][1],
			BMP_SELECT_W, BMP_SELECT_H, BMP_SELECT_PAL, BMP_SELECT_CGX+(BMP_SELECT_W*BMP_SELECT_H)*i );
		GF_BGL_BmpWinDataFill( &wk->sub_win[ADD_WIN_SELECT0+i], 0 );
	}

	// 数値表示用のBMP領域初期化
	for(i=0;i<BAG_COUNT_NUM;i++){
		GF_BGL_BmpWinAdd(
			wk->bgl, &wk->sub_win[ADD_WIN_NUM_100+i],
			BMP_NUM_FRM, BmpNumTable[i][0], BmpNumTable[i][1],
			BMP_NUM_W, BMP_NUM_H, BMP_NUM_PAL, BMP_NUM_100_CGX+(BMP_NUM_W*BMP_NUM_H)*i );
		GF_BGL_BmpWinDataFill( &wk->sub_win[ADD_WIN_NUM_100+i], 0 );
	}

	// 「捨てる」もしくは「売る」BMP領域初期化
	GF_BGL_BmpWinAdd(
		wk->bgl, &wk->sub_win[ADD_WIN_DEPOSIT],
		BMP_DEPOSIT_FRM, BMP_DEPOSIT_PX,	BMP_DEPOSIT_PY,
		BMP_DEPOSIT_W, BMP_DEPOSIT_H, BMP_DEPOSIT_PAL, BMP_DEPOSIT_CGX );
	GF_BGL_BmpWinDataFill( &wk->sub_win[ADD_WIN_DEPOSIT], 0 );

	// 「捨てる」もしくは「売る」BMP領域初期化
	GF_BGL_BmpWinAdd(
		wk->bgl, &wk->sub_win[ADD_WIN_MINITALK],
		BMP_MINITALK_FRM, BMP_MINITALK_PX,	BMP_MINITALK_PY,
		BMP_MINITALK_W, BMP_MINITALK_H, BMP_MINITALK_PAL, BMP_MINITALK_CGX );
	GF_BGL_BmpWinDataFill( &wk->sub_win[ADD_WIN_MINITALK], 0 );

	// 所持金
	GF_BGL_BmpWinAdd(
		wk->bgl, &wk->sub_win[ADD_WIN_GOLD], BMP_GOLD_FRM,
		BMP_GOLD_PX, BMP_GOLD_PY, BMP_GOLD_SX, BMP_GOLD_SY, BMP_GOLD_PAL, BMP_GOLD_CGX );
	GF_BGL_BmpWinDataFill( &wk->sub_win[ADD_WIN_GOLD], 0 );

	// どうぐを売った時に受け取るお金
	GF_BGL_BmpWinAdd(
		wk->bgl, &wk->sub_win[ADD_WIN_SALE_GOLD], BMP_GOLD_FRM,
		BMP_SALE_GOLD_PX, BMP_SALE_GOLD_PY, BMP_SALE_GOLD_W, BMP_SALE_GOLD_H,
		BMP_SALE_GOLD_PAL, BMP_SALE_GOLD_CGX );
	GF_BGL_BmpWinDataFill( &wk->sub_win[ADD_WIN_SALE_GOLD], 0 );


	MORI_PRINT("minitalk=%d\n",BMP_MINITALK_CGX+BMP_MINITALK_W*BMP_MINITALK_H);
}


//------------------------------------------------------------------
/*
 * @brief   選択したどうぐと選択肢４つのBMP領域解放
 *
 * @param	wk		バッグ画面ワーク
 *
 * @retval  none
 */
//------------------------------------------------------------------
static void SelectItemBmp_WinDelete( BAG_WORK *wk )
{
	int i;

	// ポインタがNULLの場合は抜ける
	if(wk->sub_win[ADD_WIN_SELECT_ITEM].ini==NULL){
		return;
	}

	for(i=0;i<BAG_COUNT_NUM;i++){
		GF_BGL_BmpWinOffVReq( &wk->sub_win[ADD_WIN_NUM_100+i] );
		GF_BGL_BmpWinDel( &wk->sub_win[ADD_WIN_NUM_100+i] );
		wk->sub_win[ADD_WIN_NUM_100+i].ini = NULL;
	}

	GF_BGL_BmpWinOffVReq( &wk->sub_win[ADD_WIN_SALE_GOLD] );
	GF_BGL_BmpWinDel( &wk->sub_win[ADD_WIN_SALE_GOLD] );
	wk->sub_win[ADD_WIN_SALE_GOLD].ini = NULL;

	GF_BGL_BmpWinDel( &wk->sub_win[ADD_WIN_GOLD] );
	wk->sub_win[ADD_WIN_GOLD].ini = NULL;

	GF_BGL_BmpWinDel( &wk->sub_win[ADD_WIN_MINITALK] );
	wk->sub_win[ADD_WIN_MINITALK].ini = NULL;

	GF_BGL_BmpWinOffVReq( &wk->sub_win[ADD_WIN_DEPOSIT] );
	GF_BGL_BmpWinDel( &wk->sub_win[ADD_WIN_DEPOSIT] );
	wk->sub_win[ADD_WIN_DEPOSIT].ini = NULL;

	for(i=0;i<BAG_SELECT_MENU_PLATE_NUM;i++){
		GF_BGL_BmpWinOffVReq( &wk->sub_win[ADD_WIN_SELECT0+i] );
		GF_BGL_BmpWinDel( &wk->sub_win[ADD_WIN_SELECT0+i] );
		wk->sub_win[ADD_WIN_SELECT0+i].ini = NULL;
	}
	GF_BGL_BmpWinOffVReq( &wk->sub_win[ADD_WIN_SELECT_ITEM] );
	GF_BGL_BmpWinDel( &wk->sub_win[ADD_WIN_SELECT_ITEM] );
	wk->sub_win[ADD_WIN_SELECT_ITEM].ini = NULL;
}

//============================================================================================
//	ポケット名
//============================================================================================

//--------------------------------------------------------------------------------------------
/**
 * @brief	ポケット名取得
 *
 * @param	wk		バッグ画面のワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void Bag_PocketNameMake( BAG_WORK * wk )
{
	MSGDATA_MANAGER * man;
	u16	i;

	man = MSGMAN_Create( MSGMAN_TYPE_DIRECT, ARC_MSG, NARC_msg_itempocket_dat, HEAPID_BAG );

	for( i=0; i<BAG_POKE_MAX; i++ ){
		wk->pocket_name[i]  = MSGMAN_AllocString( man, i );
	}

	MSGMAN_Delete( man );
}

//--------------------------------------------------------------------------------------------
/**
 * @brief	ポケット名解放
 *
 * @param	wk		バッグ画面のワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void Bag_PocketNameRelease( BAG_WORK * wk )
{
	u16	i;

	for( i=0; i<BAG_POKE_MAX; i++ ){
		STRBUF_Delete( wk->pocket_name[i] );
	}
}

//--------------------------------------------------------------------------------------------
/**
 * @brief	ポケット名をスクリーンに反映
 *
 * @param	wk		バッグ画面のワーク
 *
 * @return	none
 *
 *	通常のBMP処理ではないため、指定エリアのみをスクリーンに反映させる
 */
//--------------------------------------------------------------------------------------------
void Bag_PocketNameScreenPut( BAG_WORK * wk )
{
	u16	i;
	u16	ssx;

	ssx = BMP_POCKET_SX/3;

	for( i=0; i<ssx; i++ ){
		GF_BGL_ScrFill(
			wk->bgl, BMP_POCKET_FRM, BMP_POCKET_CGX+ssx+i,
			BMP_POCKET_PX+i, BMP_POCKET_PY, 1, 1, BMP_POCKET_PAL );
		GF_BGL_ScrFill(
			wk->bgl, BMP_POCKET_FRM, BMP_POCKET_CGX+BMP_POCKET_SX+ssx+i,
			BMP_POCKET_PX+i, BMP_POCKET_PY+1, 1, 1, BMP_POCKET_PAL );
	}
}

//--------------------------------------------------------------------------------------------
/**
 * アイテム名を単語登録
 *
 * @param	wk		バッグ画面のワーク
 * @param	pos		位置
 * @param	buf_id	登録位置
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ItemNameWordSet( BAG_WORK * wk, u32 pos, u32 buf_id )
{
	WORDSET_RegisterItemName( wk->wset, buf_id, Bag_PosItemGet(wk,pos,POS_GET_ID) );
}

//--------------------------------------------------------------------------------------------
/**
 * @brief	アイテム説明表示
 *
 * @param	wk		バッグ画面のワーク
 * @param	item	アイテム番号
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void Bag_ItemInfoPut( BAG_WORK * wk, u16 item )
{
	STRBUF * buf;

	if( item != 0xffff ){
		buf = STRBUF_Create( BUFLEN_ITEM_INFO, HEAPID_BAG );
		ItemInfoGet( buf, item, HEAPID_BAG );
	}else{
		buf = MSGMAN_AllocString( wk->msg_man, mes_bag_103 );
	}

	GF_STR_PrintColor(
		&wk->win[WIN_INFO], FONT_SYSTEM, buf,
		NORMAL_INFO_PX, 0, MSG_NO_PUT, BAGCOL_N_WHITE, NULL );
	STRBUF_Delete( buf );
}

//--------------------------------------------------------------------------------------------
/**
 * @brief	技マシンの情報表示
 *
 * @param	wk		バッグ画面ワーク
 * @param	item	アイテム番号
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void BagBmp_WazaMashineInfoPut( BAG_WORK * wk, u16 item )
{
	GF_BGL_BMPWIN * win;
	STRBUF * str;
	u16	waza;
	u16	prm;

	win  = &wk->win[WIN_WAZA_INFO];
	waza = GetWazaNoItem( item );

	// タイプ
	str = MSGMAN_AllocString( wk->msg_man, mes_bag_107 );
	GF_STR_PrintColor(
		win, FONT_SYSTEM, str, INFO_TYPE_PX, INFO_TYPE_PY, MSG_NO_PUT, BAGCOL_N_WHITE, NULL );
	STRBUF_Delete( str );
	// PP
	str = MSGMAN_AllocString( wk->msg_man, mes_bag_095 );
	GF_STR_PrintColor(
		win, FONT_SYSTEM, str, INFO_PP_PX, INFO_PP_PY, MSG_NO_PUT, BAGCOL_N_WHITE, NULL );
	STRBUF_Delete( str );
	// ぶんるい
	str = MSGMAN_AllocString( wk->msg_man, mes_bag_098 );
	GF_STR_PrintColor(
		win, FONT_SYSTEM, str, INFO_KIND_PX, INFO_KIND_PY, MSG_NO_PUT, BAGCOL_N_WHITE, NULL );
	STRBUF_Delete( str );
	// いりょく
	str = MSGMAN_AllocString( wk->msg_man, mes_bag_096 );
	GF_STR_PrintColor(
		win, FONT_SYSTEM, str, INFO_POW_PX, INFO_POW_PY, MSG_NO_PUT, BAGCOL_N_WHITE, NULL );
	STRBUF_Delete( str );
	// めいちゅう
	str = MSGMAN_AllocString( wk->msg_man, mes_bag_097 );
	GF_STR_PrintColor(
		win, FONT_SYSTEM, str, INFO_HIT_PX, INFO_HIT_PY, MSG_NO_PUT, BAGCOL_N_WHITE, NULL );
	STRBUF_Delete( str );

	// PP値
	prm = WT_PPMaxGet( waza, 0 );
	str = MSGMAN_AllocString( wk->msg_man, mes_bag_099 );
	WORDSET_RegisterNumber( wk->wset, 0, prm, 2, NUMBER_DISPTYPE_SPACE, NUMBER_CODETYPE_DEFAULT );
	WORDSET_ExpandStr( wk->wset, wk->expb, str );
	STRBUF_Delete( str );
	GF_STR_PrintColor(
		win, FONT_SYSTEM, wk->expb, INFO_PPNUM_PX, INFO_PPNUM_PY, MSG_NO_PUT, BAGCOL_N_WHITE, NULL );
	// 威力値
	prm = WT_WazaDataParaGet( waza, ID_WTD_damage );
	if( prm <= 1 ){
		str = MSGMAN_AllocString( wk->msg_man, msg_bag_025 );
	}else{
		str = MSGMAN_AllocString( wk->msg_man, mes_bag_100 );
	}
	WORDSET_RegisterNumber( wk->wset, 0, prm, 3, NUMBER_DISPTYPE_LEFT, NUMBER_CODETYPE_DEFAULT );
	WORDSET_ExpandStr( wk->wset, wk->expb, str );
	STRBUF_Delete( str );
	GF_STR_PrintColor(
		win, FONT_SYSTEM, wk->expb, INFO_POWNUM_PX, INFO_POWNUM_PY, MSG_NO_PUT, BAGCOL_N_WHITE, NULL );
	// 命中値
	prm = WT_WazaDataParaGet(waza,ID_WTD_hitprobability);
	if( prm == 0 ){
		str = MSGMAN_AllocString( wk->msg_man, msg_bag_025 );
	}else{
		str = MSGMAN_AllocString( wk->msg_man, mes_bag_100 );
	}
	WORDSET_RegisterNumber( wk->wset, 0, prm, 3, NUMBER_DISPTYPE_LEFT, NUMBER_CODETYPE_DEFAULT );
	WORDSET_ExpandStr( wk->wset, wk->expb, str );
	STRBUF_Delete( str );
	GF_STR_PrintColor(
		win, FONT_SYSTEM, wk->expb, INFO_HITNUM_PX, INFO_HITNUM_PY, MSG_NO_PUT, BAGCOL_N_WHITE, NULL );

	GF_BGL_BmpWinOnVReq( win );

}


//==============================================================================
/**
 * @brief   技情報消去
 *
 * @param	wk		バッグ画面ワーク
 *
 * @retval  none
 */
//==============================================================================
void BagBmp_WazaInfoClear( BAG_WORK *wk )
{
	GF_BGL_BmpWinOffVReq( &wk->win[WIN_WAZA_INFO] );
}


//--------------------------------------------------------------------------------------------
/**
 * @brief	個数表示文字列取得
 *
 * @param	wk		バッグ画面のワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void Bag_NumStrGet( BAG_WORK * wk )
{
	wk->num_str1 = MSGMAN_AllocString( wk->msg_man, msg_bag_093 );
	wk->num_str2 = MSGMAN_AllocString( wk->msg_man, msg_bag_038 );
}

//--------------------------------------------------------------------------------------------
/**
 * @brief	個数表示文字列解放
 *
 * @param	wk		バッグ画面のワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void Bag_NumStrRelease( BAG_WORK * wk )
{
	STRBUF_Delete( wk->num_str1 );
	STRBUF_Delete( wk->num_str2 );
}

//--------------------------------------------------------------------------------------------
/**
 * @brief	アイテムリスト個数表示
 *
 * @param	wk		バッグ画面のワーク
 * @param	num		個数
 * @param	y		Ｙ座標
 * @param	col		カラー
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void Bag_ItemListNumPut( BAG_WORK * wk, u16 num, u16 y, u32 col )
{
	STRBUF * expb;
	u32	siz;

	// 技マシン
	if( wk->dat->p_data[wk->dat->p_now].type == BAG_POKE_WAZA ){
//		GF_STR_PrintColor(
//			&wk->win[WIN_LIST], FONT_SYSTEM,
//			wk->num_str1, WX_POS_PX, y, MSG_NO_PUT, col, NULL );
	}else{
//		GF_STR_PrintColor(
//			&wk->win[WIN_LIST], FONT_SYSTEM,
//			wk->num_str1, NX_POS_PX, y, MSG_NO_PUT, col, NULL );
	}

	expb = STRBUF_Create( NUM_BUFLEN, HEAPID_BAG );

	WORDSET_RegisterNumber( wk->wset, 0, num, 3, NUMBER_DISPTYPE_LEFT, NUMBER_CODETYPE_DEFAULT );
	WORDSET_ExpandStr( wk->wset, expb, wk->num_str2 );

	siz = FontProc_GetPrintStrWidth( FONT_SYSTEM, expb, 0 );

	STRBUF_Delete( expb );
}


//--------------------------------------------------------------------------------------------
/**
 * @brief	技マシンのNo表示
 *
 * @param	wk		バッグ画面ワーク
 * @param	win		BMPWIN
 * @param	item	アイテムデータ
 * @param	py		表示Y座標
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void BagBmp_WazaMachineNoPut( BAG_WORK * wk, GF_BGL_BMPWIN *win, MINEITEM * item, u32 py )
{
	u16	id = item->id;

	if( id < ITEM_HIDENMASIN01 ){
		id = id - ITEM_WAZAMASIN01 + 1;
		NUMFONT_WriteSet(
			wk->num_font, NUMFONT_MARK_NO, id, 2,
			NUMFONT_MODE_ZERO, win, 0, py + WM_NO_Y_PLUS );
		Bag_ItemListNumPut( wk, item->no, py, BAGCOL_N_BLACK );
	}else{
		id = id - ITEM_HIDENMASIN01 + 1;
		NUMFONT_WriteNumber(
			wk->num_font, id, 2, NUMFONT_MODE_SPACE,
			win, NUMFONT_MARK_WIDTH, py + WM_NO_Y_PLUS );
		BAG_HidenIconPut( wk, win, 16 );
	}

}


//--------------------------------------------------------------------------------------------
/**
 * @brief	木の実のNo表示
 *
 * @param	wk		バッグ画面ワーク
 * @param	item	アイテムデータ
 * @param	py		表示Y座標
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void BagBmp_NutsNoPut( BAG_WORK * wk, MINEITEM * item, u32 py )
{
/*
	NUMFONT_WriteSet(
		wk->num_font, NUMFONT_MARK_NO, NutsNoGet(item->id)+1, 2,
		NUMFONT_MODE_ZERO, &wk->win[WIN_LIST], 0, py + WM_NO_Y_PLUS );
	Bag_ItemListNumPut( wk, item->no, py, BAGCOL_N_BLACK );
*/
}

//--------------------------------------------------------------------------------------------
/**
 * バッグ画面専用のアイコンのキャラデータを取得
 *
 * @param	wk		バッグ画面ワーク
 * @param	chr		キャラ展開場所
 *
 * @return	アーカイブデータ
 */
//--------------------------------------------------------------------------------------------
static void * ListIconCgxGet( BAG_WORK * wk, NNSG2dCharacterData ** chr )
{
	void * buf;

	buf = ArchiveDataLoadAllocByHandle( wk->gra_h, NARC_bag_gra_listicon_NCGR, HEAPID_BAG );
	NNS_G2dGetUnpackedBGCharacterData( buf, chr );
	return buf;
}

//--------------------------------------------------------------------------------------------
/**
 * 秘伝アイコン表示
 *
 * @param	wk		バッグ画面ワーク
 * @param	win		BMPWIN
 * @param	py		表示Y座標
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BAG_HidenIconPut( BAG_WORK * wk, GF_BGL_BMPWIN *win, u32 py )
{
	NNSG2dCharacterData * chr;
	void * arc_buf;
	u8	spx;

	arc_buf = ListIconCgxGet( wk, &chr );

	GF_BGL_BmpWinPrint(
		win, chr->pRawData, HIREN_ICON_PX, HIREN_ICON_PY,
		LIST_ICON_SX, LIST_ICON_SY, 0, py, HIREN_ICON_SX, HIREN_ICON_SY );

	sys_FreeMemory( HEAPID_BAG, arc_buf );
}

//--------------------------------------------------------------------------------------------
/**
 * @brief	技マシンページの「とじる」表示
 *
 * @param	wk		バッグ画面ワーク
 * @param	py		表示Y座標
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void BagBmp_WazaPageToziruPut( BAG_WORK * wk, u32 py )
{
	STRBUF * str = MSGMAN_AllocString( wk->msg_man, msg_bag_041 );

	STRBUF_Delete( str );
}


//--------------------------------------------------------------------------------------------
/**
 * 便利ボタンアイコン表示
 *
 * @param	wk		バッグ画面ワーク
 * @param	win		BMPWIN
 * @param	py		表示Y座標
 * @param	button	ボタン番号
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BagBmp_CnvButtonIconPut( BAG_WORK * wk, GF_BGL_BMPWIN *win, u32 py, int button )
{
	NNSG2dCharacterData * chr;
	void * arc_buf;
	u8	spx;

	arc_buf = ListIconCgxGet( wk, &chr );

	if(button==0){
		GF_BGL_BmpWinPrint(
			win, chr->pRawData, CNV_ICON1_PX, CNV_ICON1_PY,
			LIST_ICON_SX, LIST_ICON_SY, CNV_ICON_SCRPUT_X, py, CNV_ICON_SX, CNV_ICON_SY );
	}else{
		GF_BGL_BmpWinPrint(
			win, chr->pRawData, CNV_ICON2_PX, CNV_ICON2_PY,
			LIST_ICON_SX, LIST_ICON_SY, CNV_ICON_SCRPUT_X, py, CNV_ICON_SX, CNV_ICON_SY );

	}

	sys_FreeMemory( HEAPID_BAG, arc_buf );
}



//============================================================================================
//	メニュー
//============================================================================================

//--------------------------------------------------------------------------------------------
/**
 * @brief	メニュー項目取得
 *
 * @param	wk		バッグ画面のワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void Bag_MenuStrGet( BAG_WORK * wk )
{
	wk->menu_str[ BAG_MENU_TSUKAU ]     = MSGMAN_AllocString( wk->msg_man, msg_bag_001 );
	wk->menu_str[ BAG_MENU_ORIRU ]      = MSGMAN_AllocString( wk->msg_man, msg_bag_007 );
	wk->menu_str[ BAG_MENU_MIRU ]       = MSGMAN_AllocString( wk->msg_man, msg_bag_017 );
	wk->menu_str[ BAG_MENU_UMERU ]		= MSGMAN_AllocString( wk->msg_man, mes_bag_104 );
	wk->menu_str[ BAG_MENU_HIRAKU ]		= MSGMAN_AllocString( wk->msg_man, mes_bag_105 );
	wk->menu_str[ BAG_MENU_SUTERU ]     = MSGMAN_AllocString( wk->msg_man, msg_bag_002 );
	wk->menu_str[ BAG_MENU_TOUROKU ]    = MSGMAN_AllocString( wk->msg_man, msg_bag_003 );
	wk->menu_str[ BAG_MENU_KAIZYO ]     = MSGMAN_AllocString( wk->msg_man, msg_bag_019 );
	wk->menu_str[ BAG_MENU_MOTASERU ]   = MSGMAN_AllocString( wk->msg_man, msg_bag_004 );
	wk->menu_str[ BAG_MENU_TAGUWOMIRU ] = MSGMAN_AllocString( wk->msg_man, msg_bag_005 );
	wk->menu_str[ BAG_MENU_KETTEI ]		= MSGMAN_AllocString( wk->msg_man, msg_bag_006 );
	wk->menu_str[ BAG_MENU_YAMERU ]     = MSGMAN_AllocString( wk->msg_man, msg_bag_009 );
	wk->menu_str[ BAG_MENU_IDOU ]       = MSGMAN_AllocString( wk->msg_man, msg_bag_094 );
	wk->menu_str[ BAG_MENU_URU ]        = MSGMAN_AllocString( wk->msg_man, mes_shop_103 );
	wk->menu_str[ BAG_MENU_TSUKAU_NP ]  = MSGMAN_AllocString( wk->msg_man, msg_bag_001 );
	wk->menu_str[ BAG_MENU_TOMERU ]		= MSGMAN_AllocString( wk->msg_man, msg_bag_menu_ex_01 );
}

//--------------------------------------------------------------------------------------------
/**
 * @brief	メニュー項目解放
 *
 * @param	wk		バッグ画面のワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void Bag_MenuStrRelease( BAG_WORK * wk )
{
	u16	i;

	for( i=0; i<BAG_MENU_MAX; i++ ){
		STRBUF_Delete( wk->menu_str[i] );
	}
}

//--------------------------------------------------------------------------------------------
/**
 * @brief	メニュー作成
 *
 * @param	wk		バッグ画面のワーク
 * @param	tbl		メニューテーブル
 * @param	max		メニュー数
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void Bag_ItemMenuSet( BAG_WORK * wk, u8 * tbl, u8 max )
{
	BMPMENU_HEADER hed;
	POCKET_DATA * pocket;
	STRBUF * msg;
	STRBUF * expb;
	u16	i;
	u16	info;

	info = WIN_MENU_INFO;

	if( wk->dat->p_data[wk->dat->p_now].type == BAG_POKE_WAZA ){
		GF_BGL_BmpWinDataFill( &wk->win[WIN_WAZA_INFO], FBMP_COL_NULL );
		BagBmp_WazaMashineInfoPut( wk, wk->dat->ret_item );
		GF_BGL_BmpWinOnVReq( &wk->win[WIN_INFO] );
		BagObj_WazaIconPut( wk, wk->dat->ret_item, ACT_ON );
		BAGMAIN_InfoWinLoad( wk, FALSE );
	}

	// 説明
	BmpTalkWinWrite(
		&wk->win[info], WINDOW_TRANS_OFF, TALK_SUB_WIN_CGX_NUM, TALKWIN_PAL );

	GF_BGL_BmpWinDataFill( &wk->win[info], FBMP_COL_WHITE );

	pocket = &wk->dat->p_data[ wk->dat->p_now ];

	if( wk->dat->mode == BAG_MODE_N_PLANTER &&
		BAGMAIN_NPlanterUseCheck( pocket->type, wk->dat->ret_item ) == FALSE ){
		msg = MSGMAN_AllocString( wk->msg_man, mes_bag_112 );
	}else{
		msg = MSGMAN_AllocString( wk->msg_man, msg_bag_042 );
	}

	expb = STRBUF_Create( MENU_INFO_STRLEN, HEAPID_BAG );

	ItemNameWordSet( wk, pocket->scr+wk->cursor_pos-8, 0 );
	WORDSET_ExpandStr( wk->wset, expb, msg );

	GF_STR_PrintSimple( &wk->win[info], FONT_TALK, expb, 0, 0, MSG_NO_PUT, NULL );

	STRBUF_Delete( expb );
	STRBUF_Delete( msg );

	GF_BGL_BmpWinOnVReq( &wk->win[info] );
}


//==============================================================================
/**
 * @brief   選択したどうぐの説明文章を描画する
 *
 * @param   wk			バッグ画面ワーク
 * @param   win			BMPWIN
 * @param   item_id		アイテム番号
 *
 * @retval  none
 */
//==============================================================================
void BagBmp_ItemExplainPut( BAG_WORK *wk, GF_BGL_BMPWIN *win, int item_id)
{
	// どうぐの説明を上画面に表示する
	GF_BGL_BmpWinDataFill( win, FBMP_COL_NULL );
	Bag_ItemInfoPut( wk, item_id );
	GF_BGL_BmpWinOnVReq( win );

}

//==============================================================================
/**
 * @brief   バッグの説明をクリアする
 *
 * @param   wk			バッグ画面ワーク
 * @param   win			BMPWIN
 *
 * @retval  none
 */
//==============================================================================
void BagBmp_ItemExplainClear( BAG_WORK *wk, GF_BGL_BMPWIN *win )
{
	// どうぐの説明をクリアする
	GF_BGL_BmpWinDataFill( win, FBMP_COL_NULL );
	GF_BGL_BmpWinOnVReq( win );

}

//
//==============================================================================
/**
 * @brief	ポケット説明表示
 *
 * @param	wk			バッグ画面ワーク
 * @param	win			BMPWIN
 * @param	pocket		ポケット番号
 *
 * @retval  none
 */
//==============================================================================
void BagBmp_PocketExplainPut( BAG_WORK * wk, GF_BGL_BMPWIN * win, int pocket )
{
	STRBUF * buf = MSGMAN_AllocString( wk->msg_man, msg_bag_pocket_01+pocket );

	GF_BGL_BmpWinDataFill( win, FBMP_COL_NULL );
	GF_STR_PrintColor(
		win, FONT_SYSTEM, buf, NORMAL_INFO_PX, 0, MSG_NO_PUT, BAGCOL_N_WHITE, NULL );
	STRBUF_Delete( buf );
	GF_BGL_BmpWinOnVReq( win );
}


//==============================================================================
/**
 * @brief   「●●を　どうしますか？」等の1列ウインドウ消去
 *
 * @param   wk		バッグ画面ワーク
 *
 * @retval  none
 */
//==============================================================================
void BagBmp_MenuInfoClear( BAG_WORK *wk )
{
	BmpTalkWinClear( &wk->win[WIN_MENU_INFO], WINDOW_TRANS_OFF );
	GF_BGL_BmpWinOffVReq( &wk->win[WIN_MENU_INFO] );

}

//--------------------------------------------------------------------------------------------
/**
 * @brief	メニュー破棄（通常）
 *
 * @param	wk		バッグ画面のワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void Bag_ItemMenuExit( BAG_WORK * wk )
{
	u32	info;
	int i;

	info = WIN_MENU_INFO;

//	if( wk->dat->p_data[wk->dat->p_now].type != BAG_POKE_WAZA ){
		BagBmp_MenuInfoClear( wk );
//	}

	// 選択したどうぐの表示領域解放
	SelectItemBmp_WinDelete( wk );

	BagObj_WazaIconPut( wk, 0, ACT_OFF );
}


//==============================================================================
/**
 * @brief   どうぐ選択メニューからどうぐ移動画面への遷移用
 *
 * @param   wk		バッグ画面ワーク
 *
 * @retval  none
 */
//==============================================================================
void BagBmp_ItemMenu2MoveMenu( BAG_WORK *wk )
{
	// 選択したどうぐの表示領域解放
	SelectItemBmp_WinDelete( wk );
}

//--------------------------------------------------------------------------------------------
/**
 * @brief	入れ替えメッセージ表示（どこにいれますか？）
 *
 * @param	wk		バッグ画面のワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void BagBmp_ItemChgInfoMsgSet( BAG_WORK * wk )
{
	STRBUF * msg;
	STRBUF * expb;

	GF_BGL_BmpWinDataFill( &wk->win[WIN_MENU_INFO], 0xff );

	// 「●●を　いどうさせます」
	msg  = MSGMAN_AllocString( wk->msg_man, msg_bag_045 );
	expb = STRBUF_Create( BUFLEN_ITEM_INFO, HEAPID_BAG );

	ItemNameWordSet( wk, wk->irekae_pos, 0 );
	WORDSET_ExpandStr( wk->wset, expb, msg );

	// ウインドウ枠描画
	BmpTalkWinWrite(
		&wk->win[WIN_MENU_INFO], WINDOW_TRANS_OFF, TALK_SUB_WIN_CGX_NUM, TALKWIN_PAL );

#if	GS_BTS5597_20090718_FIX
	GF_STR_PrintColor(
		&wk->win[WIN_MENU_INFO], FONT_TALK, expb,
		0, 0, MSG_NO_PUT, BAGCOL_N_BLACK, NULL );
#else
	GF_STR_PrintColor(
		&wk->win[WIN_MENU_INFO], FONT_SYSTEM, expb,
		0, 0, MSG_NO_PUT, BAGCOL_N_BLACK, NULL );
#endif

	GF_BGL_BmpWinOnVReq( &wk->win[WIN_MENU_INFO] );

	STRBUF_Delete( expb );
	STRBUF_Delete( msg );
}


//--------------------------------------------------------------------------------------------
/**
 * @brief	捨てる関連ウィンドウセット
 *
 * @param	wk		バッグ画面のワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void Bag_DelNumSelWinSet( BAG_WORK * wk )
{
	POCKET_DATA * pocket;
	STRBUF * msg;
	STRBUF * expb;
	u16	i;

	Bag_SubNumPut( wk, NUM_DIGIT_2 );

	BmpTalkWinWrite(
		&wk->win[WIN_MENU_INFO], WINDOW_TRANS_OFF, TALK_WIN_CGX_NUM, TALKWIN_PAL );
	GF_BGL_BmpWinDataFill( &wk->win[WIN_MENU_INFO], FBMP_COL_WHITE );

	msg    = MSGMAN_AllocString( wk->msg_man, msg_bag_054 );
	expb   = STRBUF_Create( MENU_INFO_STRLEN, HEAPID_BAG );
	pocket = &wk->dat->p_data[ wk->dat->p_now ];

	ItemNameWordSet( wk, pocket->scr+pocket->cur-1, 0 );
	WORDSET_ExpandStr( wk->wset, expb, msg );

	GF_STR_PrintSimple( &wk->win[WIN_MENU_INFO], FONT_TALK, expb, 0, 0, MSG_NO_PUT, NULL );

	GF_BGL_BmpWinOnVReq( &wk->win[WIN_MENU_INFO] );

	STRBUF_Delete( expb );
	STRBUF_Delete( msg );
}

#define BAG_NUM_MAX	( 999 )

//--------------------------------------------------------------------------------------------
/**
 * @brief	捨てる個数表示
 *
 * @param	wk		バッグ画面のワーク
 * @param	type	NUM_DIGIT_2 or NUM_DIGIT_3 (２桁か３桁か）
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void Bag_SubNumPut( BAG_WORK * wk, int type )
{
	GF_BGL_BMPWIN * win;
	STRBUF * numstr;
	u32	siz,tmp,keta,n,i;

	GF_ASSERT( wk->sel_num < (BAG_NUM_MAX+1) );

	// 文字列バッファ確保
	numstr = STRBUF_Create( 2, HEAPID_BAG );

	// ２桁か３桁か
	if(type==NUM_DIGIT_2){
		keta=10;
	}else{
		keta=100;
	}

	tmp = wk->sel_num;
	for(i=0;i<type;i++){
		n = tmp/keta;

		// １桁ごとに文字列バッファ展開
		STRBUF_SetNumber( numstr, n, 1, NUMBER_DISPTYPE_LEFT, NUMBER_CODETYPE_DEFAULT );
		tmp -= n*keta;
		keta/=10;

		win = &wk->sub_win[ADD_WIN_NUM_100+i];
		GF_BGL_BmpWinDataFill( win, 0 );

		// 描画
		GF_STR_PrintColor( win, FONT_SYSTEM, numstr, 0, 4, MSG_NO_PUT, BAGCOL_N_BLACK, NULL );
		GF_BGL_BmpWinOnVReq( win );


	}

	STRBUF_Delete( numstr );
}

//--------------------------------------------------------------------------------------------
/**
 * @brief	捨てる関連ウィンドウ破棄
 *
 * @param	wk		バッグ画面のワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void Bag_DelNumSelWinExit( BAG_WORK * wk )
{
	BmpTalkWinClear( &wk->win[WIN_MENU_INFO], WINDOW_TRANS_OFF );

	GF_BGL_BmpWinOffVReq( &wk->win[WIN_MENU_INFO] );

	GF_BGL_BmpWinOnVReq( &wk->win[WIN_INFO] );
}

//--------------------------------------------------------------------------------------------
/**
 * @brief	「すててもいいですか？」表示
 *
 * @param	wk		バッグ画面のワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void Bag_SubTalkWinSet( BAG_WORK * wk )
{
	POCKET_DATA * pocket;
	STRBUF * msg;
	u16	i;

	msg    = MSGMAN_AllocString( wk->msg_man, msg_bag_056 );
	pocket = &wk->dat->p_data[ wk->dat->p_now ];

	ItemNameWordSet( wk, pocket->scr+wk->cursor_pos-8, 0 );
	WORDSET_RegisterNumber(
		wk->wset, 1, wk->sel_num, 3, NUMBER_DISPTYPE_LEFT, NUMBER_CODETYPE_DEFAULT );

	WORDSET_ExpandStr( wk->wset, wk->expb, msg );
	STRBUF_Delete( msg );
	wk->midx = Bag_TalkMsgPrint( wk, BAG_TALK_FULL );
}


//--------------------------------------------------------------------------------------------
/**
 * @brief	会話（風）メッセージ表示
 *
 * @param	wk		バッグ画面ワーク
 * @param	type	BAG_TALK_FULL=画面一杯, BAG_TALK_MINI=画面2/3
 *
 * @return	メッセージID
 */
//--------------------------------------------------------------------------------------------
u8 Bag_TalkMsgPrint( BAG_WORK * wk, int type )
{
	u8	idx;
	GF_BGL_BMPWIN *win;
	if(type==BAG_TALK_FULL){
		win = &wk->win[WIN_TALK];
	}else{
		// 呼び出せない時がある
		GF_ASSERT( wk->sub_win[ADD_WIN_MINITALK].ini!=NULL );
		win = &wk->sub_win[ADD_WIN_MINITALK];
	}

	GF_BGL_BmpWinDataFill( win, 15 );
	BmpTalkWinWrite( win, WINDOW_TRANS_OFF, TALK_SUB_WIN_CGX_NUM, TALKWIN_PAL );
	GF_BGL_BmpWinOnVReq( win );

	MsgPrintSkipFlagSet( MSG_SKIP_ON );
	MsgPrintAutoFlagSet( MSG_AUTO_OFF );

	idx = GF_STR_PrintSimple(	win, FONT_TALK,wk->expb, 0, 0,
								CONFIG_GetMsgPrintSpeed( wk->cfg ), BAG_TalkMsgCallBack );

	return idx;
}

//--------------------------------------------------------------------------------------------
/**
 * 会話（風）メッセージコールバック
 *
 * @param	mph		メッセージ描画データ
 * @param	value	コールバックナンバ
 *
 * @retval	"TRUE = 待ち"
 * @retval	"FALSE = 次の処理へ"
 */
//--------------------------------------------------------------------------------------------
static BOOL BAG_TalkMsgCallBack( MSG_PRINT_HEADER * mph, u16 value )
{
	switch( value ){
	case 1:		// SE終了待ち
		return Snd_SePlayCheckAll();

	case 2:		// ME終了待ち
		return Snd_MePlayCheckBgmPlay();

	case 3:		// "きどうした"
		Snd_SePlay( SEQ_SE_DP_PC_LOGIN );
		break;

	case 4:		// "きどうした"のSE終了待ち
		return Snd_SePlayCheck( SEQ_SE_DP_PC_LOGIN );
	}

	return FALSE;
}

//--------------------------------------------------------------------------------------------
/**
 * @brief	はい・いいえセット
 *
 * @param	wk		バッグ画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void Bag_YesNoSelInit( BAG_WORK * wk )
{
	TOUCH_SW_PARAM param;

	param.p_bgl     = wk->bgl;
	param.bg_frame  = GF_BGL_FRAME1_S;
	param.char_offs = BAG_BMP_YESNO_CHAROFFSET;
	param.pltt_offs =  9;
	param.x         = 25;
	param.y         = 6;
	param.kt_st     = 0;
	param.key_pos   = 0;
	param.key_pos   = 0;
	param.type      = TOUCH_SW_TYPE_S;

	wk->tss = TOUCH_SW_AllocWork( HEAPID_BAG );
	TOUCH_SW_Init( wk->tss, &param );
}

//==============================================================================
/**
 * @brief   はい・いいえ処理用ワーク解放
 *
 * @param   wk		バッグワーク
 *
 * @retval  none
 */
//==============================================================================
void Bag_YesNoSelEnd( BAG_WORK *wk )
{
	TOUCH_SW_FreeWork( wk->tss );
}

//--------------------------------------------------------------------------------------------
/**
 * @brief	売却数選択ウィンドウ表示
 *
 * @param	wk		バッグ画面ワーク
 * @param	flg		0 = ウィンドウ枠込み表示, 0 != BMPのみ表示
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void Bag_SaleNumWinPut( BAG_WORK * wk )
{
	GF_BGL_BMPWIN * win;
	STRBUF * strb;
	u32	siz;

	win = &wk->sub_win[ADD_WIN_SALE_GOLD];

	GF_BGL_BmpWinDataFill( win, 0 );

	strb = MSGMAN_AllocString( wk->msg_man, mes_shop_100 );
	WORDSET_RegisterNumber(
		wk->wset, 0, wk->sel_price*wk->sel_num, 6,
		NUMBER_DISPTYPE_SPACE, NUMBER_CODETYPE_DEFAULT );
	WORDSET_ExpandStr( wk->wset, wk->expb, strb );
	siz = FontProc_GetPrintStrWidth( FONT_SYSTEM, wk->expb, 0 );
	GF_STR_PrintColor( win, FONT_SYSTEM, wk->expb, 0, 4, MSG_NO_PUT, BAGCOL_N_BLACK, NULL );
	GF_BGL_BmpWinOnVReq( win );
	STRBUF_Delete( strb );
}


//--------------------------------------------------------------------------------------------
/**
 * @brief	所持金ウィンドウ表示
 *
 * @param	wk		バッグ画面ワーク
 * @param	flg		0 = ウィンドウ枠込み表示, 0 != BMPのみ表示
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void Bag_GoldWinPut( BAG_WORK * wk, u8 flg )
{
	GF_BGL_BMPWIN * win;
	STRBUF * strb;
	STRBUF * expandstr = STRBUF_Create( BAG_TMPMSG_SIZ, HEAPID_BAG );
	u32	siz;

	win = &wk->sub_win[ADD_WIN_GOLD];

	if( flg == 0 ){
		GF_BGL_BmpWinDataFill( win, 0 );
		strb = MSGMAN_AllocString( wk->msg_man, mes_shop_097 );
		GF_STR_PrintColor( win, FONT_SYSTEM, strb, 4, 0, MSG_NO_PUT, BAGCOL_N_BLACK,NULL );
		STRBUF_Delete( strb );
	}else{
		GF_BGL_BmpWinFill( win, 0, 0, 16, GOLD_EX, 16 );
	}

	strb = MSGMAN_AllocString( wk->msg_man, mes_shop_098 );
	WORDSET_RegisterNumber(
		wk->wset, 0, MyStatus_GetGold(wk->myst),
		6, NUMBER_DISPTYPE_SPACE, NUMBER_CODETYPE_DEFAULT );

	WORDSET_ExpandStr( wk->wset, expandstr, strb );
	siz = FontProc_GetPrintStrWidth( FONT_SYSTEM, expandstr, 0 );
	GF_STR_PrintColor(
		win, FONT_SYSTEM, expandstr, GOLD_EX-(siz+8)-4, 16, MSG_NO_PUT, BAGCOL_N_BLACK,NULL );
	GF_BGL_BmpWinOnVReq( win );
	STRBUF_Delete( strb );
	STRBUF_Delete( expandstr );
}



//--------------------------------------------------------------------------------------------
/**
 * @brief	「ポフィンのかず」表示
 *
 * @param	wk		バッグ画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void BagBmp_PorutoWinPut( BAG_WORK * wk )
{
	GF_BGL_BMPWIN * win;
	STRBUF * str;
	u32	siz;

	win = &wk->win[WIN_PORUTO];

	GF_BGL_BmpWinDataFill( win, 15 );
	BmpMenuWinWrite( win, WINDOW_TRANS_OFF, MENU_WIN_CGX_NUM, MENU_WIN_PAL );

	str = MSGMAN_AllocString( wk->msg_man, msg_bag_polto_01 );
	GF_STR_PrintSimple( win, FONT_SYSTEM, str, 0, 0, MSG_NO_PUT, NULL );
	STRBUF_Delete( str );

	str = MSGMAN_AllocString( wk->msg_man, msg_bag_polto_02 );

	//PORUTO_APP_DEL	08.06.24
	WORDSET_RegisterNumber(
		wk->wset, 0, 0,
		3, NUMBER_DISPTYPE_SPACE, NUMBER_CODETYPE_DEFAULT );

	WORDSET_ExpandStr( wk->wset, wk->expb, str );
	STRBUF_Delete( str );
	siz = FontProc_GetPrintStrWidth( FONT_SYSTEM, wk->expb, 0 );
	GF_STR_PrintSimple(
		win, FONT_SYSTEM, wk->expb, BMP_PORUTO_SX*8-siz, 16, MSG_NO_PUT, NULL );

	GF_BGL_BmpWinOnVReq( win );
}


//------------------------------------------------------------------
/**
 * @brief   右下の「やめる」文字列描画
 *
 * @param   wk		バッグ画面ワーク
 * @param	mode	0 = 中央に表示, 1 = ボタンマークあり時
 *
 * @retval  none
 */
//------------------------------------------------------------------
void BagBmp_CancelPrint( BAG_WORK *wk, u32 mode )
{
	STRBUF *str  = MSGMAN_AllocString( wk->msg_man, msg_bag_009 );

	OS_Printf("win_cancel->ini = %08x\n",(u32)wk->win[WIN_CANCEL].ini);

	GF_BGL_BmpWinDataFill( &wk->win[WIN_CANCEL], 0 );

	if( mode == 0 ){
		GF_STR_PrintColor(
			&wk->win[WIN_CANCEL], FONT_SYSTEM, str,
			(GF_BGL_BmpWinGet_SizeX(&wk->win[WIN_CANCEL])*8-FontProc_GetPrintStrWidth(FONT_SYSTEM,str,0))/2,
			0,
			MSG_NO_PUT, BAGCOL_N_WHITE, NULL );
	}else{
		GF_STR_PrintColor(
			&wk->win[WIN_CANCEL], FONT_SYSTEM, str,
			13, 0, MSG_NO_PUT, BAGCOL_N_WHITE, NULL );
	}

	GF_BGL_BmpWinOnVReq( &wk->win[WIN_CANCEL] );

	STRBUF_Delete( str );
}

// 各ポケットの最大数
static const u8 PocketMax[] = {
	BAG_NORMAL_ITEM_MAX,	// 道具ポケット最大数
	BAG_DRUG_ITEM_MAX,		// 薬ポケット最大数
	BAG_BALL_ITEM_MAX,		// モンスターボールポケット最大数
	BAG_WAZA_ITEM_MAX,		// 技マシンポケット最大数
	BAG_NUTS_ITEM_MAX,		// 木の実ポケット最大数
	BAG_SEAL_ITEM_MAX,		// シールポケット最大数
	BAG_BATTLE_ITEM_MAX,	// 戦闘用アイテムポケット最大数
	BAG_EVENT_ITEM_MAX,		// 大切な物ポケット最大数
};

//------------------------------------------------------------------
/**
 * @brief   指定位置のアイテムの格納位置を取得
 *
 * @param   p		ポケットデータ
 * @param	index	ポケット位置
 * @param	target	アイテム位置
 *
 * @return	格納位置
 */
//------------------------------------------------------------------
static int GetPocketItemRoute( POCKET_DATA *p, int index, int target )
{
	int i,count=0;

	for(i=0;i<PocketMax[index];i++){
		if( p->item[i].id > 0 && p->item[i].no > 0 ){
			count++;
			if(count==target+1){
				break;
			}
		}
	}
	return i;
}

//==============================================================================
/**
 * @brief   どうぐ名描画
 *
 * @param   wk		バッグ画面ワーク
 * @param   scr		スクロールポイント（金銀では６の倍数になる）
 * @param   pos		カーソル位置(ー１だと全て名前のみ、この値に０〜５が入っている場合はどうぐ移動モード）
 * @param   mode	ITEMPRINT_NORMAL:どうぐ通常表示  ITEMPRINT_INSERT:どうぐ移動モード
 *
 * @retval  none
 */
//==============================================================================
void BagBmp_ItemNamePrint( BAG_WORK *wk, int scr, int pos, enum ITEMPRINT_MODE mode )
{
	int i,count;
	POCKET_DATA * pocket = &wk->dat->p_data[wk->dat->p_now];
	int num = pocket->max - pocket->scr;
	u16	on_bmp, off_bmp;

	OS_Printf("ポケット%dには%d個 開始個数は%d \n", wk->dat->p_now, pocket->max, pocket->scr);

	if( num > BAG_PAGE_ITEM_NUM ){
		num = BAG_PAGE_ITEM_NUM;
	}

	if( wk->itemlist_swap == 0 ){
		on_bmp  = ADD_WIN_ITEM0;
		off_bmp = ADD_WIN_ITEM0_S;
	}else{
		on_bmp  = ADD_WIN_ITEM0_S;
		off_bmp = ADD_WIN_ITEM0;
	}
	wk->itemlist_swap ^= 1;

	// どうぐリストもBMP領域確保
	ItemListBmp_WinInit( wk );
	for(i=0;i<BAG_PAGE_ITEM_NUM;i++){
		GF_BGL_BmpWinDataFill( &wk->sub_win[on_bmp+i], 0 );
		GF_BGL_BmpWinOffVReq( &wk->sub_win[off_bmp+i] );
	}

	count=0;
	OS_Printf("アイテム探索開始位置は%d, scr=%d\n ",GetPocketItemRoute( pocket, wk->dat->p_now, scr ), scr);
	for(i=GetPocketItemRoute( pocket, wk->dat->p_now, scr );i<PocketMax[wk->dat->p_now];i++){
		if( pocket->item[i].id != 0 && pocket->item[i].no > 0 ){

			if(mode==ITEMPRINT_NORMAL){
				// ウインドウにどうぐ名・個数を描画
				itemname_print( wk, &wk->sub_win[on_bmp+count], wk->itemname[i], pocket, i );
			}else{
				if( i == wk->irekae_pos ){
					// ウインドウにどうぐ名・個数を描画
					itemname_print( wk, &wk->sub_win[on_bmp+count], wk->itemname[i], pocket, i );
				}else{
					// どうぐ名のみ描画
					GF_STR_PrintColor( &wk->sub_win[on_bmp+count], FONT_SYSTEM,
										wk->itemname[i],0, 16, MSG_NO_PUT, BAGCOL_N_BLACK, NULL );
				}
			}
			count++;
			if(count>=num){
				break;
			}
		}
	}
	for(i=0;i<BAG_PAGE_ITEM_NUM;i++){
		GF_BGL_BmpWinOnVReq( &wk->sub_win[on_bmp+i] );
	}
}


//==============================================================================
/**
 * @brief   選択されたどうぐの名前を中央に表示
 *
 * @param   wk		バッグ画面ワーク
 * @param   scr		スクロールカウンタ
 * @param   pos		位置
 *
 * @retval  none
 */
//==============================================================================
void BagBmp_SelectItemPrint( BAG_WORK *wk, int scr, int pos )
{
	int i;
	POCKET_DATA * pocket = &wk->dat->p_data[wk->dat->p_now];
	pos = scr+pos;

	// どうぐリストすべて消去
	for(i=0;i<BAG_PAGE_ITEM_NUM;i++){
		GF_BGL_BmpWinOffVReq( &wk->sub_win[ADD_WIN_ITEM0+i] );
	}
	ItemListBmp_WinDelete( wk );

	// ページ番号非表示
	GF_BGL_BmpWinOffVReq( &wk->win[WIN_PAGE] );

	// 選択したどうぐを表示する領域の確保
	SelectItemBmp_WinInit(wk);

	itemname_print( wk, &wk->sub_win[ADD_WIN_SELECT_ITEM], wk->itemname[pos], pocket, pos );

	GF_BGL_BmpWinOnVReq( &wk->sub_win[ADD_WIN_SELECT_ITEM] );
}

//==============================================================================
/**
 * @brief   中央に表示のどうぐ名をオフ
 *
 * @param   wk		バッグ画面ワーク
 *
 * @retval  none
 */
//==============================================================================
void BagBmp_SelectItemClear( BAG_WORK *wk )
{
	GF_BGL_BmpWinOffVReq( &wk->sub_win[ADD_WIN_SELECT_ITEM] );
}

//------------------------------------------------------------------
/**
 * @brief   どうぐ名と所持数を描画する
 *
 * @param   wk			バッグ画面ワーク
 * @param   win		    BMPWIN
 * @param   str		    文字列バッファ
 * @param   pocket		ポケット構造体ポンイタ
 * @param   index		ポケット内どうぐの位置番号
 *
 * @retval  none
 */
//------------------------------------------------------------------
static void itemname_print( BAG_WORK *wk,  GF_BGL_BMPWIN *win, STRBUF *str, POCKET_DATA *pocket, int index )
{

	switch(pocket->type){

	// 技マシンの場合
	case BAG_POKE_WAZA:
		GF_STR_PrintColor(
			win, FONT_SYSTEM, str,	0, 0, MSG_NO_PUT, BAGCOL_N_BLACK, NULL );
		// わざNOの描画
		BagBmp_WazaMachineNoPut( wk, win, &pocket->item[index], 16 );

		// わざマシンだけ個数描画
		if( pocket->item[index].id>=ITEM_WAZAMASIN01 &&  pocket->item[index].id<=ITEM_WAZAMASIN92){
			// 個数描画
			ItemNumPrint( wk->wset, wk->msg_man, win, pocket->item[index].no );
		}
		break;


	// たいせつなどうぐ
	case BAG_POKE_EVENT:
		// 名前描画
		GF_STR_PrintColor(win, FONT_SYSTEM, str,	0, 0, MSG_NO_PUT, BAGCOL_N_BLACK, NULL );

		// とうろくボタンで使用中か？
		if( MyItem_CnvButtonItemGet( wk->myitem ) == pocket->item[index].id ){
			BagBmp_CnvButtonIconPut( wk, win, 16, 0 );
		}
		// とうろくボタンで使用中か？
		if( MyItem_CnvButton2ItemGet( wk->myitem ) == pocket->item[index].id ){
			BagBmp_CnvButtonIconPut( wk, win, 16, 1 );
		}

		break;

	// 通常のどうぐ
	default:
		GF_STR_PrintColor( win, FONT_SYSTEM, str,	0, 0, MSG_NO_PUT, BAGCOL_N_BLACK, NULL );
		// 個数描画
		ItemNumPrint( wk->wset, wk->msg_man, win, pocket->item[index].no );

	}
}

//------------------------------------------------------------------
/**
 * @brief   指定のどうぐの個数をBMPに描画
 *
 * @param   wset		ワードセット
 * @param	msg_man		メッセージマネージャ
 * @param   win			BMPWIN
 * @param   num			個数
 *
 * @return	none
 */
//------------------------------------------------------------------
static void	ItemNumPrint( WORDSET *wset, MSGDATA_MANAGER *msg_man, GF_BGL_BMPWIN *win, int num )
{
	STRBUF *str;

	WORDSET_RegisterNumber( wset, 0, num, 3, NUMBER_DISPTYPE_LEFT, NUMBER_CODETYPE_DEFAULT );

	str = MSGDAT_UTIL_AllocExpandString( wset, msg_man, mes_bag_093, HEAPID_BAG );

	GF_STR_PrintColor(	win, FONT_SYSTEM, str,
						48, 16, MSG_NO_PUT, BAGCOL_N_BLACK, NULL );

	STRBUF_Delete(str);
}


//==============================================================================
/**
 * @brief   ページ番号を表示する
 *
 * @param   wk		バッグ画面ワーク
 * @param   max		ページ数
 * @param   scr		スクロールカウンタ
 * @param   pos		カーソル位置
 *
 * @retval  none
 */
//==============================================================================
void BagBmp_PageNoPrint( BAG_WORK *wk, int max, int scr, int pos )
{
	STRBUF *str;
	int page_now = (scr+pos)/BAG_PAGE_ITEM_NUM+1;
	int page_max;

	if(max==0){
		page_max = 1;
	}else{
		page_max = (max+5)/BAG_PAGE_ITEM_NUM;
	}

	GF_BGL_BmpWinDataFill( &wk->win[WIN_PAGE], 0 );

	WORDSET_RegisterNumber( wk->wset, 0, page_now, 3, NUMBER_DISPTYPE_SPACE, NUMBER_CODETYPE_DEFAULT );
	WORDSET_RegisterNumber( wk->wset, 1, page_max, 3, NUMBER_DISPTYPE_SPACE, NUMBER_CODETYPE_DEFAULT );
	str = MSGDAT_UTIL_AllocExpandString( wk->wset, wk->msg_man, msg_bag_022_01, HEAPID_BAG );
	GF_STR_PrintColor(
		&wk->win[WIN_PAGE], FONT_SYSTEM, str, 0, 0, MSG_NO_PUT, BAGCOL_B_WHITE, NULL );

	GF_BGL_BmpWinOnVReq( &wk->win[WIN_PAGE] );

	STRBUF_Delete( str );
}



//==============================================================================
/**
 * @brief   選択肢メニューの文字列を表示する
 *
 * @param   win			BMPWIN
 * @param   string		文字列テーブル
 * @param	menuitem	メニュー番号
 *
 * @retval  none
 */
//==============================================================================
void BagSelectMenu_StringPrint( GF_BGL_BMPWIN *win, STRBUF *string[], const u8 menuitem )
{

	GF_BGL_BmpWinDataFill( win, 0 );

	if(menuitem!=255){
		GF_STR_PrintColor(
			win, FONT_SYSTEM, string[menuitem],
			(GF_BGL_BmpWinGet_SizeX(win)*8-FontProc_GetPrintStrWidth(FONT_SYSTEM,string[menuitem],0))/2,
			0,
			MSG_NO_PUT, BAGCOL_N_WHITE, NULL );
	}
	GF_BGL_BmpWinOnVReq( win );

	OS_Printf("menuitem = %d\n", menuitem);
}

//==============================================================================
/**
 * @brief   表示した選択肢メニューの文字列をクリア
 *
 * @param   win		BMPWIN
 *
 * @retval  none
 */
//==============================================================================
void BagSelectMenu_Clear( GF_BGL_BMPWIN *win )
{
	int i;
	for( i=0;i<4;i++ ){
		GF_BGL_BmpWinOffVReq( &win[i] );
	}
}

//==============================================================================
/**
 * @brief   「捨てる」文字列描画
 *
 * @param   wk		バッグ画面ワーク
 *
 * @retval  none
 */
//==============================================================================
void BagBmp_DepositPrint( BAG_WORK *wk )
{
	GF_STR_PrintColor( &wk->sub_win[ADD_WIN_DEPOSIT], FONT_SYSTEM, wk->menu_str[ BAG_MENU_SUTERU ],
							5, 0, MSG_NO_PUT, BAGCOL_N_WHITE, NULL );

	GF_BGL_BmpWinOnVReq( &wk->sub_win[ADD_WIN_DEPOSIT] );

}

//==============================================================================
/**
 * @brief   「売る」文字列描画
 *
 * @param   wk		バッグ画面ワーク
 *
 * @retval  none
 */
//==============================================================================
void BagBmp_SalePrint( BAG_WORK *wk )
{
	GF_STR_PrintColor( &wk->sub_win[ADD_WIN_DEPOSIT], FONT_SYSTEM, wk->menu_str[ BAG_MENU_URU ],
							5, 0, MSG_NO_PUT, BAGCOL_N_WHITE, NULL );

	GF_BGL_BmpWinOnVReq( &wk->sub_win[ADD_WIN_DEPOSIT] );

}

//==============================================================================
/**
 * @brief   捨てる文字列クリア
 *
 * @param   wk
 *
 * @retval  none
 */
//==============================================================================
void BagBmp_DepositSaleClear( BAG_WORK *wk )
{
	GF_BGL_BmpWinOffVReq( &wk->sub_win[ADD_WIN_DEPOSIT] );
}

//==============================================================================
/**
 * @brief   「やめる」の表示OFF
 *
 * @param   wk
 *
 * @retval  none
 */
//==============================================================================
void BagBmp_CancelOff( BAG_WORK *wk )
{
	GF_BGL_BmpWinOffVReq( &wk->win[WIN_CANCEL] );
}